/* Reset and base styles for consistent rendering */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow: hidden;
}

/* Main container with responsive height handling */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
}

/* Adjust height for full browser view */
@media (min-height: 500px) {
    .container {
        height: 90vh;
    }
}

/* Control panel styling with mobile-first approach */
.control-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}

.control-label {
    font-weight: 600;
    color: #4a5568;
    font-size: 14px;
    white-space: nowrap;
}

/* Custom slider styling for better touch interaction */
.slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.value-display {
    font-weight: bold;
    color: #667eea;
    min-width: 20px;
    text-align: center;
}

/* Button group with responsive layout */
.button-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px; /* Touch-friendly height */
    white-space: nowrap;
}

.start-btn {
    background: #48bb78;
    color: white;
}

.start-btn:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

.pause-btn {
    background: #ed8936;
    color: white;
}

.pause-btn:hover:not(:disabled) {
    background: #dd6b20;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(237, 137, 54, 0.3);
}

.reset-btn {
    background: #e53e3e;
    color: white;
}

.reset-btn:hover {
    background: #c53030;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.3);
}

.control-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Main simulation area with flexible layout */
.simulation-area {
    flex: 1;
    display: flex;
    gap: 8px;
    min-height: 0; /* Allow flex shrinking */
}

/* Car animation section */
.car-section {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.road {
    position: relative;
    height: 60px;
    background: linear-gradient(to bottom, #718096 0%, #4a5568 50%, #718096 100%);
    border-radius: 8px;
    overflow: hidden;
    border: 3px solid #2d3748;
}

.car {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%) scaleX(-1);
    font-size: 24px;
    transition: left 0.1s linear;
    z-index: 2;
}

.distance-markers {
    position: absolute;
    bottom: -25px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #4a5568;
    font-weight: 600;
}

.marker {
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Graph section styling */
.graph-section {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.graph-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#graph-canvas {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    max-width: 100%;
    max-height: 100%;
}

.graph-labels {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.y-label {
    position: absolute;
    left: -40px;
    top: 50%;
    transform: translateY(-50%) rotate(-90deg);
    font-weight: 600;
    color: #4a5568;
    font-size: 12px;
}

.x-label {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 600;
    color: #4a5568;
    font-size: 12px;
}

.current-values {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
}

/* Information panel with key concepts */
.info-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.concept-box {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 8px;
}

.concept-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #4a5568;
    flex: 1;
    min-width: 120px;
    justify-content: center;
}

.concept-icon {
    font-size: 14px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 4px;
        gap: 4px;
    }
    
    .simulation-area {
        flex-direction: column;
    }
    
    .control-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .speed-control {
        justify-content: center;
    }
    
    .button-group {
        justify-content: center;
    }
    
    .concept-box {
        flex-direction: column;
    }
    
    .concept-item {
        min-width: auto;
    }
}

/* Tooltip styling for better UX */
[title] {
    cursor: help;
}

/* Animation for smooth interactions */
.control-btn, .slider::-webkit-slider-thumb {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus styles for accessibility */
.control-btn:focus,
.slider:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}
